﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;

namespace HZY.Admin.Controllers.Sys
{
    using HZY.Toolkit;
    using HZY.Logic.Sys;
    using HZY.Models.Sys;
    using HZY.DTO;
    using HZY.DTO.Sys;

    public class AppLogController : ApiBaseController
    {
        protected Sys_AppLogLogic logic { get; }

        public AppLogController(Sys_AppLogLogic _logic)
        {
            this.logic = _logic;
        }

        #region 基础 CURD

        /// <summary>
        /// 查询数据列表
        /// </summary>
        /// <param name="Page"></param>
        /// <param name="Rows"></param>
        /// <param name="Search"></param>
        /// <returns></returns>
        [HttpPost("FindList/{Page}/{Rows}"), ServiceFilter(typeof(Core.HZYApiAuthorizationCheckAttribute))]
        public async Task<ApiResult> FindListAsync(int Page, int Rows, [FromBody] Sys_AppLog Search)
        {
            var tableVM = await this.logic.FindListAsync(Page, Rows, Search, null, null);
            return this.JsonOk(tableVM);
        }

        /// <summary>
        /// 保存数据
        /// </summary>
        /// <returns></returns>
        [HttpPost("Save"), ServiceFilter(typeof(Core.HZYApiAuthorizationCheckAttribute))]
        public async Task<ApiResult> SaveAsync([FromBody]Sys_AppLog Model)
        {
            await this.logic.SaveAsync(Model);
            return this.JsonOk();
        }

        /// <summary>
        /// 删除数据
        /// </summary>
        /// <param name="Ids"></param>
        /// <returns></returns>
        [HttpPost("Delete"), ServiceFilter(typeof(Core.HZYApiAuthorizationCheckAttribute))]
        public async Task<ApiResult> DeleteAsync([FromBody]List<Guid> Ids)
        {
            await this.logic.DeleteAsync(Ids);
            return this.JsonOk();
        }

        /// <summary>
        /// 根据Id 加载表单数据
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        [HttpPost("LoadForm/{Id?}"), ServiceFilter(typeof(Core.HZYApiAuthorizationCheckAttribute))]
        public async Task<ApiResult> LoadFormAsync(Guid Id)
        {
            return this.JsonOk(await this.logic.LoadFormAsync(Id));
        }

        #endregion







    }
}